package ilvonen.ihstatistics.models;

public class Skater extends Player {

	private int _plusMinus;//plus-miinustilasto
	private int _ppGoals;//ylivoimamaalit
	private int _shGoals;//alivoimamaalit
	private int _winningGoals;//voittomaalit
	private int _shots;//laukaukset
	private int _shootingPercentage;
	private int _faceoffWins;
	private int _faceoffLosses;
	private int _faceoffWinPercentage;
	private int _hits;//taklaukset
	private int _blocks;//vastustajan vedon blokkaukset
	private int _timeOnIcePerGame;
	private int _shifts;//vaihdot
	private double _averageShiftPerGame;
	
	public Skater(/*int id, int active, String role, String fName, String lName, String sleeveNr, String height, String weight, String shoots, String bDay, String bPlace*/) {
		super(/*id, active, role, fName, lName, sleeveNr, height, weight, shoots, bDay, bPlace*/);
	}

	/**
	 * @return the _plusMinus
	 */
	public int get_plusMinus() {
		return _plusMinus;
	}

	/**
	 * @param _plusMinus the _plusMinus to set
	 */
	public void set_plusMinus(int _plusMinus) {
		this._plusMinus = _plusMinus;
	}

	/**
	 * @return the _ppGoals
	 */
	public int get_ppGoals() {
		return _ppGoals;
	}

	/**
	 * @param _ppGoals the _ppGoals to set
	 */
	public void set_ppGoals(int _ppGoals) {
		this._ppGoals = _ppGoals;
	}

	/**
	 * @return the _shGoals
	 */
	public int get_shGoals() {
		return _shGoals;
	}

	/**
	 * @param _shGoals the _shGoals to set
	 */
	public void set_shGoals(int _shGoals) {
		this._shGoals = _shGoals;
	}

	/**
	 * @return the _winningGoals
	 */
	public int get_winningGoals() {
		return _winningGoals;
	}

	/**
	 * @param _winningGoals the _winningGoals to set
	 */
	public void set_winningGoals(int _winningGoals) {
		this._winningGoals = _winningGoals;
	}

	/**
	 * @return the _shots
	 */
	public int get_shots() {
		return _shots;
	}

	/**
	 * @param _shots the _shots to set
	 */
	public void set_shots(int _shots) {
		this._shots = _shots;
	}

	/**
	 * @return the _shootingPercentage
	 */
	public int get_shootingPercentage() {
		return _shootingPercentage;
	}

	/**
	 * @param _shootingPercentage the _shootingPercentage to set
	 */
	public void set_shootingPercentage(int _shootingPercentage) {
		this._shootingPercentage = _shootingPercentage;
	}

	/**
	 * @return the _faceoffWins
	 */
	public int get_faceoffWins() {
		return _faceoffWins;
	}

	/**
	 * @param _faceoffWins the _faceoffWins to set
	 */
	public void set_faceoffWins(int _faceoffWins) {
		this._faceoffWins = _faceoffWins;
	}

	/**
	 * @return the _faceoffLosses
	 */
	public int get_faceoffLosses() {
		return _faceoffLosses;
	}

	/**
	 * @param _faceoffLosses the _faceoffLosses to set
	 */
	public void set_faceoffLosses(int _faceoffLosses) {
		this._faceoffLosses = _faceoffLosses;
	}

	/**
	 * @return the _faceoffWinPercentage
	 */
	public int get_faceoffWinPercentage() {
		return _faceoffWinPercentage;
	}

	/**
	 * @param _faceoffWinPercentage the _faceoffWinPercentage to set
	 */
	public void set_faceoffWinPercentage(int _faceoffWinPercentage) {
		this._faceoffWinPercentage = _faceoffWinPercentage;
	}

	/**
	 * @return the _hits
	 */
	public int get_hits() {
		return _hits;
	}

	/**
	 * @param _hits the _hits to set
	 */
	public void set_hits(int _hits) {
		this._hits = _hits;
	}

	/**
	 * @return the _blocks
	 */
	public int get_blocks() {
		return _blocks;
	}

	/**
	 * @param _blocks the _blocks to set
	 */
	public void set_blocks(int _blocks) {
		this._blocks = _blocks;
	}

	/**
	 * @return the _timeOnIcePerGame
	 */
	public int get_timeOnIcePerGame() {
		return _timeOnIcePerGame;
	}

	/**
	 * @param _timeOnIcePerGame the _timeOnIcePerGame to set
	 */
	public void set_timeOnIcePerGame(int _timeOnIcePerGame) {
		this._timeOnIcePerGame = _timeOnIcePerGame;
	}

	/**
	 * @return the _shifts
	 */
	public int get_shifts() {
		return _shifts;
	}

	/**
	 * @param _shifts the _shifts to set
	 */
	public void set_shifts(int _shifts) {
		this._shifts = _shifts;
	}

	/**
	 * @return the _averageShiftPerGame
	 */
	public double get_averageShiftPerGame() {
		if(_shifts > 0){
			_averageShiftPerGame = _timeOnIcePerGame / _shifts * 1.0;
		}
		return _averageShiftPerGame;
	}

	/**
	 * @param _averageShiftPerGame the _averageShiftPerGame to set
	 */
	public void set_averageShiftPerGame(int _averageShiftPerGame) {
		this._averageShiftPerGame = _averageShiftPerGame;
	}
	
	public void calculateStats(){
		if(_stats.size() > 0){
			for (Stat stat : _stats) {
				if(stat.get_statName().equals(_pfsOttelu)){
					_matches++;
				}
				else if(stat.get_statName().equals(_pfsVoitto)){
					_victories++;
				}
				else if(stat.get_statName().equals(_pfsTappio)){
					_losses++;
				}
				else if(stat.get_statName().equals(_pfsJatkoaikaTappio)){
					_otLosses++;
				}
				else if(stat.get_statName().equals(_pfsRankkariTappio)){
					_soLosses++;
				}
				else if(stat.get_statName().equals(_pfsJatkoaikaVoitto)){
					_otVictories++;
				}
				else if(stat.get_statName().equals(_pfsRankkariVoitto)){
					_soVictories++;
				}
				else if(stat.get_statName().equals(_pfsMaali)){
					_goals++;
				}
				else if(stat.get_statName().equals(_pfsSyotto)){
					_assists++;
				}
				else if(stat.get_statName().equals(_pfsRangaistus)){
					_penalties++;
				}
				else if(stat.get_statName().equals(_pfsPlusMiinus)){
					_plusMinus++;
				}
				else if(stat.get_statName().equals(_pfsYlivoimamaali)){
					_ppGoals++;
				}
				else if(stat.get_statName().equals(_pfsAlivoimamaali)){
					_shGoals++;
				}
				else if(stat.get_statName().equals(_pfsVoittomaali)){
					_winningGoals++;
				}
				else if(stat.get_statName().equals(_pfsLaukaus)){
					_shots++;
				}
				else if(stat.get_statName().equals(_pfsTaklaus)){
					_hits++;
				}
				else if(stat.get_statName().equals(_pfsBlokkaus)){
					_blocks++;
				}
				else if(stat.get_statName().equals(_pfsPeliaika)){
					/*
					 * Each shift makes one stat and the value of that stat is the time pleyer was on ice during that shift.
					 */
					_timeOnIcePerGame += stat.get_value();
					_shifts++;
				}
			}
		}
	}
}
